<template>
    <div class="login">
        <div>
            <img src="../../assets/img/orange.png" alt />
        </div>
        <van-form @submit="onSubmit">
            <van-field
                v-model="user.phone"
                name="手机号"
                placeholder="手机号"
                :rules="[{ required: true, message: '请填写手机号' }]"
            />
            <van-field
                v-model="user.password"
                type="password"
                name="密码"
                placeholder="密码"
                :rules="[{ required: true, message: '请填写密码' }]"
            />
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit">提交</van-button>
            </div>
        </van-form>
    </div>
</template>

<script>
import { Toast } from "vant";
import { reqLogin } from "../../http/api";
export default {
    data() {
        return {
            user: {
                phone: "",
                password: ""
            }
        }
    },
    methods: {
        //点了登陆
        onSubmit() {
            reqLogin(this.user).then((res) => {
                if (res.data.code == 200) {
                    Toast.success(res.data.msg)
                    //cen登陆标识,
                    localStorage.setItem("isLogin", JSON.stringify(res.data.list))
                    this.$router.push("/index/home")
                }
            })
        }
    }
}
</script>

<style scoped lang="less">
.login {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;
}
.login div:nth-child(1) {
    height: 0.9rem;
    align-items: center;
    margin: 0 auto;
}

</style>